import 'package:flutter/material.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return BottomWidget();
  }
}

class BottomWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _BottomWidgetState();
  }
}

class _BottomWidgetState extends State<BottomWidget> {
  var _eachView = [EachView("page1"), EachView("page2")];
  var _index = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _eachView[_index],
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          _onFloatButtonClick(context);
        },
        tooltip: 'Increment',
        child: Icon(
          Icons.add,
          color: Colors.white,
        ),
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      bottomNavigationBar: BottomAppBar(
        color: Colors.lightBlue,
        shape: CircularNotchedRectangle(),
        child: Row(
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: <Widget>[
            IconButton(
                icon: Icon(Icons.home),
                color: Colors.white,
                onPressed: () => onTapClick(0)),
            IconButton(
                icon: Icon(Icons.airport_shuttle),
                color: Colors.white,
                onPressed: () => onTapClick(1)),
          ],
        ),
      ),
    );
  }

  void _onFloatButtonClick(BuildContext context) {
    Navigator.of(context)
        .push(MaterialPageRoute(builder: (context) => EachView2("333")));
  }

  onTapClick(int i) {
    setState(() {
      this._index = i;
    });
  }
}

class EachView extends StatelessWidget {
  String title;
  EachView(this.title);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
        appBar: AppBar(title: Text("$title")), body: Text("EachView $title"));
  }
}

class EachView2 extends StatelessWidget {
  String title;
  EachView2(this.title);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
        appBar: AppBar(
          title: Text("$title"),
          elevation: 0.0,
        ),
        body: Text("EachView $title"));
  }
}
